/**
 *@brief	�û���һЩ��ݽṹ���Լ���ɺ�ɾ����������뷽�� 
 *@date		2015-12-14
 *@author	ikangtai-wangwei
 *@copyright iknagtai corp
 **/
#include<stdlib.h>
#include"common.h"
#include<stdio.h>
#include "al.h"
#include <time.h> 
#include <string.h>
#include "specialCondition.h"
#include "debugTest.h"
#include "inputPeriod.h"
#include "inputBBT.h"
#include "inputMucus.h"
#include "inputTestOV.h"
//#include "typeTrans.h"

#define LOGW(...) __android_log_print(ANDROID_LOG_WARN,"jni" ,__VA_ARGS__) // 定义LOGW类型

/*
�½�num��cycleUnitDS����Ҫԭ�����ڣ�ÿ�����һ��DS����Ҫ��Ӧ��������ڲ���struct tm 
*/
cycleUnitDS * createCycleUnitNum(int num){
	cycleUnitDS *result = (cycleUnitDS *)malloc(sizeof(cycleUnitDS)*num);
	if(result == NULL) return NULL;
	int x = 0;
	for(;x< num;x++){
		result[x].cycleNumber = 0;
		result[x].ovulationDayUserRecordBasis = 0;
		int cx = 0;
		for(;cx< 26; cx++){
			result[x].cycleData[cx] = 0; 	
		} 
	}
	return result;
}
bool freeCycleUnit(cycleUnitDS *cycleUnit){
	if(cycleUnit==NULL) return true;
	free(cycleUnit);
	cycleUnit = NULL;
	return true;	
}

dayUnitDSInput *createDayInputNum(int num){
	dayUnitDSInput *result = (dayUnitDSInput *)malloc(sizeof(dayUnitDSInput)*num);
	if(result == NULL) return NULL;
	int x = 0;
	for(;x < num; x++){
		result[x].BBT = 0;
		result[x].cervicalMunusRecord = 0;
		result[x].dayOfCycle = 0;
		result[x].menstruationRecord = 0;
		result[x].ovulationTestResult = 0;
		result[x].tempFlag = 0;
	
		result[x].date = 0;
		
	}
	return result;
} 

bool freeDayInput(dayUnitDSInput *data){
	if(data==NULL) return true;
	free(data);
	data = NULL;
	return true;
}


dayUnitDSOutput *createDayOutputNum(int num){
	dayUnitDSOutput *result = (dayUnitDSOutput *)malloc(sizeof(dayUnitDSOutput)*num);
	if(result == NULL) return NULL;
	int x = 0;
	for(;x<num;x++){
		result[x].dayOfCycle = 0;
		result[x].homePageConceptionChance = 0;
		result[x].homePageMenstruationEnd = 0;
		result[x].homePageNextMenstruation = 0;
		result[x].homePageOvulation = 0;
		result[x].periodAchieveConfirm = 0;
		result[x].periodAchieveForecast = 0;
		result[x].periodAvoidConfirm = 0;
		result[x].periodAvoidForecast = 0;
		result[x].date = 0;
	}
	return result;
}

bool freeDayOutput(dayUnitDSOutput *data){
	if(data==NULL) return true;
	free(data);
	data = NULL;
	return true;
}


/*type : 
1  the new resigter user first use this app
2  input ps
3  input pe
4  delete ps note:cycleInput  
5  delete pe 
6  fixPS
7  inputPeriod
8  inputVisualPeriod
11 input BBT
12 input Mocus
13 input record
14 delete record             note:delete the record value should set 4*/
int inputAlForIOS(int type,dayUnitDSInput* daysInput,int daysInputLength,cycleUnitDS *cycleInput,int cycleInputLength,
userUnitDS* userData,long firstPS,dayUnitDSOutput* daysOutput,int *daysOutputLength,cycleUnitDS *cyclesOutput,int *cyclesOutputLength){
	#ifdef TEST_ALL_PRINT
	LOGW("ALOUTPUT-----:call the al for ios --> the type:%d! \n",type);
	#endif
	//#ifdef JAVA_OUTPUT
	LOGW("ALOUTPUT----:call the al for type \n");
	//#endif
	int filer = 1;
	//checkInputDataIsRight(type,daysInput,daysInputLength,cycleInput,cycleInputLength,userData,firstPS);
	if(filer != 1){
		return ERROR_CODE;
	}
	
	int filer2 = 0;
	if(type == INPUTPS || type == INPUTPE || type == DELETEPS || type == DELETEPS){
		if(userData->averageCycleLength>150 || userData->averageOvulationDay>130 || userData->averageMenstruationLength > 20){
			#ifdef JAVA_OUTPUT
			LOGW("ALOUTPUT----:call the al for Line125 return userdata is abnormal\n");
			#endif
			return ALL_DATA_DELETE;
		}
		filer2 = checkAllPsHaveCycleConfirmPS(type,daysInput,daysInputLength,cycleInput,cycleInputLength);
		
		if(filer2 == ERROR_CODE){
			//����1��ת2���㷨
			if(type == DELETEPS || type == DELETEPS){
				int changeMens = 0;
				for(; changeMens < daysInputLength; changeMens++){
					if(daysInput[changeMens].menstruationRecord == 255 || daysInput[changeMens].menstruationRecord == 254){
						daysInput[changeMens].menstruationRecord = 0 ;
					}
				}
			}
			//transV1TOV2DS_V2_Filer(daysInputLength,daysInput,daysOutput,cyclesOutput,userData,daysOutputLength,cyclesOutputLength);
			#ifdef JAVA_OUTPUT
			LOGW("ALOUTPUT----:call the al for line142 return 234\n");
			#endif
			return  ALL_DATA_DELETE;
		}
	}
	
	 
	if(type == 1){
		//user first use this app
		//check the param
		#ifdef TEST_ALL_PRINT
		showTimeToDate(firstPS);
		#endif 
		#ifdef JAVA_OUTPUT
		LOGW("ALOUTPUT----:call the al type 1 start\n ");
		#endif
		int result = theFirstUse(firstPS,userData->averageMenstruationLength,userData->averageCycleLength,
		userData->menstruationLengthError,userData->cycleLengthError,cyclesOutput,cyclesOutputLength,daysOutput,daysOutputLength,userData);	
		#ifdef TEST_ALL_PRINT
		LOGW("ALOUTPUT-----:theFirstUse start!\n");
		#endif
		#ifdef JAVA_OUTPUT
		LOGW("ALOUTPUT----:call the al type 1 end\n ");
		#endif
		if(result == ERROR_CODE) {
			LOGW("something wrong when using theFirstUse Function!");
		}
		return result;
	}else if(type == INPUTPS || type == FIXFUTURE){
		#ifdef JAVA_OUTPUT
		LOGW("ALOUTPUT----:call the al type 2 start\n ");
		#endif
		int result = 0;
		int x = 0;
		for(; x < daysInputLength; x++){
			if(daysInput[x].menstruationRecord == 255){
				break;
			}
		}
		int y = 0;
		for(; y < daysInputLength; y++){
			if(daysInput[y].menstruationRecord == 254){
				break;
			}
		}
		#ifdef JAVA_OUTPUT
		LOGW("ALOUTPUT----:call the al type 2 start   1\n ");
		#endif
		if(x == daysInputLength){
		#ifdef TEST_ALL_PRINT
			LOGW("ALOUTPUT-----: periodInputStart error:not find PS!\n");
		#endif	
			return ERROR_CODE;
		}
		#ifdef JAVA_OUTPUT
		LOGW("ALOUTPUT----:call the al type 2 start   2\n ");
		#endif
		time_t ps = daysInput[x].date;
		time_t pe = 0;
		if(y != daysInputLength) {
			pe = daysInput[y].date;	
			int diff = getDaysDiff(&ps,&pe);
			if(diff > 15 || diff < 0) pe = 0;
		}
		
		int cycleLocation = -99;
		int psFlag = findNewPSLocation(daysInput,daysInputLength,ps,cycleInput,cycleInputLength,&cycleLocation);
		if(psFlag == 1){
		#ifdef JAVA_OUTPUT
		LOGW("ALOUTPUT----:call the al type 2 start psFlag 1\n ");
		#endif
			if(cycleLocation != -99){
				// input new PS
				#ifdef TEST_ALL_PRINT
				LOGW("ALOUTPUT-----:periodStartInput in psFlag 1 input new ps!\n");
				#endif
				result = periodInputStart(ps,pe,cycleInput+cycleLocation,cyclesOutput,cyclesOutputLength,userData,daysOutput,daysOutputLength);
			}else{
				#ifdef TEST_ALL_PRINT
				LOGW("ALOUTPUT-----:periodStartInput error did not find cycleLocation in psFlag 1!\n");
				#endif
				return ERROR_CODE;	
			}
		#ifdef JAVA_OUTPUT
		LOGW("ALOUTPUT----:call the al type 2 start psFlag 1 end\n ");
		#endif
		}else if(psFlag == 2){
		#ifdef JAVA_OUTPUT
		LOGW("ALOUTPUT----:call the al type 2 start psFlag 2\n ");
		#endif	
			if(cycleLocation != -99){
				// input new PS
				#ifdef TEST_ALL_PRINT
				LOGW("ALOUTPUT-----:periodStartInput in psFlag 2 fix ps!\n");
				#endif
				if(cycleInputLength == 1){
					//this is should use the firstPS
					#ifdef TEST_ALL_PRINT
					LOGW("ALOUTPUT-----:periodStartInput in psFlag 2 fix ps only one cycle should not be here\n");
					#endif
					result = theFirstUse(ps,userData->averageMenstruationLength,userData->averageCycleLength,
						userData->menstruationLengthError,userData->cycleLengthError,cyclesOutput,cyclesOutputLength,daysOutput,daysOutputLength,userData);
					return ALL_DATA_DELETE;
				}else{
					int fixPSx = 0;
					#ifdef TEST_ALL_PRINT
					LOGW("ALOUTPUT-----:periodStartInput in psFlag 2 fix ps start\n");
					#endif
					time_t psRight = ps;
					time_t psWrong = cycleInput[cycleLocation].cycleData[2];
					if(psRight == psWrong){
						pe = ps+(userData->averageMenstruationLength-1)*3600*24;
						result = fixFuture(ps,pe,cycleInput+cycleLocation-1,cyclesOutput,cyclesOutputLength,userData,daysOutput,daysOutputLength);
					}else{
						if(cycleInput[cycleLocation].cycleData[3] > 100){
							pe = cycleInput[cycleLocation].cycleData[3];
						}
						result = fixPS(psRight,psWrong,pe,cycleInput+cycleLocation-1, cyclesOutput,cyclesOutputLength,
						  	 userData,daysOutput,daysOutputLength);	
					}
					
					#ifdef TEST_ALL_PRINT
					LOGW("ALOUTPUT-----:periodStartInput in psFlag 2 fix ps end\n");
					#endif
				}
				
				
			
			}else{
				#ifdef TEST_ALL_PRINT
				LOGW("ALOUTPUT-----:periodStartInput error did not find cycleLocation in psFlag 2!\n");
				#endif
				return ERROR_CODE;	
			}
		#ifdef JAVA_OUTPUT
		LOGW("ALOUTPUT----:call the al type 2 start psFlag 2 end\n ");
		#endif
		}else if(psFlag == 3){
			#ifdef TEST_ALL_PRINT
			LOGW("ALOUTPUT-----:periodStartInput this is input old ps start!\n");
			#endif
			int result = changePastInfo_inputPeriod_filer(daysInputLength,daysInput,cycleInput,cycleInputLength,daysOutput,
						cyclesOutput,userData,daysOutputLength,cyclesOutputLength);
			#ifdef TEST_ALL_PRINT
			LOGW("ALOUTPUT-----:periodStartInput this is input old ps end!\n");
			#endif
		}
		#ifdef JAVA_OUTPUT
		LOGW("ALOUTPUT----:call the al type 2 end\n ");
		#endif
		
		
		#ifdef TEST_ALL_PRINT
		LOGW("ALOUTPUT-----:periodInputStart end!\n");
		#endif
		if(result == ERROR_CODE){
			LOGW("something wrong when using periodInputStart Function!");
			
		}
		return result;
	}else if(type == INPUTPE){
		#ifdef JAVA_OUTPUT
		LOGW("ALOUTPUT----:call the al type 3 start\n ");
		#endif
		int x = 0;
		int result = 0;
		for(; x < daysInputLength; x++){
			if(daysInput[x].menstruationRecord == 254){
				break;
			}
		}
		if(x == daysInputLength){
			#ifdef TEST_ALL_PRINT
			LOGW("ALOUTPUT-----: periodInputEnd error:not find PE!\n");
			#endif	
			return ERROR_CODE;
		}
		time_t pe = daysInput[x].date;
		int cycleLocation = -99;
		int peFlag = findNewPELocation(daysInput,daysInputLength,pe,cycleInput,cycleInputLength,&cycleLocation);
		if(peFlag == 1 || peFlag == 2){
			result = periodInputEnd(pe,cycleInput+cycleLocation,cyclesOutput,cyclesOutputLength,userData,daysOutput,daysOutputLength);
		}else if(peFlag == 3){
			#ifdef TEST_ALL_PRINT
			LOGW("ALOUTPUT-----:changePastInfo_inputPeriod end!\n");
			#endif
			result = changePastInfo_inputPeriod_filer(daysInputLength,daysInput,cycleInput,cycleInputLength,daysOutput,
						cyclesOutput,userData,daysOutputLength,cyclesOutputLength);
			#ifdef TEST_ALL_PRINT
			LOGW("ALOUTPUT-----:changePastInfo_inputPeriod end!\n");
			#endif
				
		}
		#ifdef JAVA_OUTPUT
		LOGW("ALOUTPUT----:call the al type 3 end\n ");
		#endif
		if(result == ERROR_CODE){
			LOGW("something wrong when using inputPE Function!");
		}
		return result;
	}else if(type == DELETEPS){
		#ifdef JAVA_OUTPUT
		LOGW("ALOUTPUT----:call the al type 5 start\n ");
		#endif
		int x = 0;
		int result = 0;
		for(; x < daysInputLength; x++){
			if(daysInput[x].menstruationRecord == 255){
				break;
			}
		}
		if(x == daysInputLength){
		#ifdef TEST_ALL_PRINT
			LOGW("ALOUTPUT-----: perioddeleteStart error:not find PS!\n");
		#endif	
			return ERROR_CODE;
		}
		time_t ps = daysInput[x].date;
		int cycleLocation = -99;
		int psFlag = findOldPSLocation(daysInput,daysInputLength,ps,cycleInput,cycleInputLength,&cycleLocation);
		if(psFlag == 1){
			if(cycleLocation != -99){
				if(cycleInputLength == 1){
					//����û�ֻ��һ�����ڣ���ɾ����ֱ�ӷ��ش�����
					return ERROR_CODE; 
				}else{
					result = deleteThisPS(ps,cycleInput+cycleLocation-1,cyclesOutput,cyclesOutputLength,userData,daysOutput,daysOutputLength);
					#ifdef TEST_ALL_PRINT
					LOGW("ALOUTPUT-----:periodInputStart end!\n");
					#endif
					if(result==ERROR_CODE){
						LOGW("something wrong when using deletePS Function!");
					}
					return 236;
				}
			}else{
			#ifdef TEST_ALL_PRINT
				LOGW("ALOUTPUT-----: perioddeleteStart error:not find PS!\n");
			#endif	
				return ERROR_CODE;	
			}
			
		}else if(psFlag == 3){
			#ifdef TEST_ALL_PRINT
			LOGW("ALOUTPUT-----:changePastInfo_deletePeriod end!\n");
			#endif
			result = changePastInfo_deletePeriod(daysInputLength,daysInput,cycleInput,cycleInputLength,daysOutput,
						cyclesOutput,userData,daysOutputLength,cyclesOutputLength);
			#ifdef TEST_ALL_PRINT
			LOGW("ALOUTPUT-----:changePastInfo_deletePeriod end!\n");
			#endif
			
		}else{
			return ERROR_CODE;
		}
		#ifdef JAVA_OUTPUT
		LOGW("ALOUTPUT----:call the al type 5 end\n ");
		#endif
		if(result == ERROR_CODE){
			LOGW("something wrong when using changePastInfo_deletePeriod Function!");
		}
		return result;
	}else if(type == DELETEPE){
		#ifdef JAVA_OUTPUT
		LOGW("ALOUTPUT----:call the al type 6 start\n ");
		#endif
		int x = 0;
		int result = 0;
		for(; x < daysInputLength; x++){
			if(daysInput[x].menstruationRecord == 254){
				break;
			}
		}
		if(x == daysInputLength){
		#ifdef TEST_ALL_PRINT
			LOGW("ALOUTPUT-----: perioddeleteEnd error:not find PS!\n");
		#endif	
			return ERROR_CODE;
		}
		time_t pe = daysInput[x].date;
		int cycleLocation = -99;
		int peFlag = findOldPELocation(daysInput,daysInputLength,pe,cycleInput,cycleInputLength,&cycleLocation);
		if(peFlag == 1){
			#ifdef TEST_ALL_PRINT
			LOGW("ALOUTPUT-----:deleteThisPE Start!\n");
			#endif
			result = deleteThisPE(pe,cycleInput+cycleLocation,cyclesOutput,cyclesOutputLength,userData,daysOutput,daysOutputLength);
			#ifdef TEST_ALL_PRINT
			LOGW("ALOUTPUT-----:deleteThisPE end!\n");
			#endif
		}else if(peFlag == 3){
			return 0;
		}else{
			return ERROR_CODE;
		}
		if(result == ERROR_CODE){
			LOGW("something wrong when using deletePe Function!");
		}
		#ifdef JAVA_OUTPUT
		LOGW("ALOUTPUT----:call the al type 6 end\n ");
		#endif
		return result;
	}else if(type == INPUTVISUALPS){
		int result = 0;
		int x = 0;
		for(; x < daysInputLength; x++){
			if(daysInput[x].menstruationRecord == 255){
				break;
			}
		}
		if(x == daysInputLength){
		#ifdef TEST_ALL_PRINT
			LOGW("ALOUTPUT-----: INPUTVISUALPS error:not find PS!\n");
		#endif	
			return ERROR_CODE;
		}
		time_t ps = daysInput[x].date;
		time_t pe = ps + 24*3600*userData->averageMenstruationLength;
		if(cycleInputLength == 1){
			result = inputVisualPeriod(ps,cycleInput,cyclesOutput,cyclesOutputLength,userData,daysOutput,daysOutputLength);
       
		}else{
			int diff1 = getDaysDiff(&(cycleInput[cycleInputLength-1].cycleData[2]),&ps);
			int diff2 = getDaysDiff(&(cycleInput[cycleInputLength-2].cycleData[2]),&ps);
			if(diff1 < diff2){
				result = inputVisualPeriod(ps,cycleInput+cycleInputLength-1,cyclesOutput,cyclesOutputLength,userData,daysOutput,daysOutputLength);
			}else{
				#ifdef TEST_ALL_PRINT
        		LOGW("ALOUTPUT-----:inputVisualPeriod error cycle is not in sort!\n");
        		#endif
        		return ERROR_CODE;
			}
		}
		#ifdef TEST_ALL_PRINT
        LOGW("ALOUTPUT-----:inputVisualPeriod end!\n");
        #endif
		
	}
	
	/*
	else if(type == 2){
		 
		int x = 0;
		for(; x < daysInputLength; x++){
			if(daysInput[x].menstruationRecord == 1){
				break;
			}
		}
		if(x == daysInputLength){
		#ifdef TEST_ALL_PRINT
			LOGW("ALOUTPUT-----: periodInputStart error:not find PS!\n");
		#endif	
			return ERROR_CODE;
		}
		
		
		
		bool result = periodInputStart(daysInput[x].date,cycleInput,cyclesOutput,cyclesOutputLength,userData,daysOutput,daysOutputLength);
		#ifdef TEST_ALL_PRINT
		LOGW("ALOUTPUT-----:periodInputStart end!\n");
		#endif
		if(result == ERROR_CODE){
			LOGW("something wrong when using periodInputStart Function!");
			
		}
		return result;
	}else if(type == 3){
		
		int x = 0;
		for(; x < daysInputLength; x++){
			if(daysInput[x].menstruationRecord == 2){
				break;
			}
		}
		
		
		
		
		
		int result = periodInputEnd(daysInput[x].date,cycleInput,cyclesOutput,cyclesOutputLength,userData,daysOutput,daysOutputLength);
		#ifdef TEST_ALL_PRINT
		LOGW("ALOUTPUT-----:periodInputEnd end!\n");
		#endif
		if(!result){
			LOGW("something wrong when using periodInputEnd Function!");
		}
		return result;
	}else if(type == 4){
		int x = 0;
		for(; x < daysInputLength; x++){
			if(daysInput[x].menstruationRecord == 1){
				break;
			}
		}
		int result = deleteThisPS(daysInput[x].date,cycleInput,cyclesOutput,cyclesOutputLength,userData,daysOutput,daysOutputLength);
		#ifdef TEST_ALL_PRINT
		LOGW("ALOUTPUT-----:periodInputStart end!\n");
		#endif
		if(!result){
			LOGW("something wrong when using deletePS Function!");
		}
		return result;		
	}else if(type == 5){
		int x = 0;
		for(; x < daysInputLength; x++){
			if(daysInput[x].menstruationRecord == 2){
				break;
			}
		}
		int result = deleteThisPE(daysInput[x].date,cycleInput,cyclesOutput,cyclesOutputLength,userData,daysOutput,daysOutputLength);
		#ifdef TEST_ALL_PRINT
		LOGW("ALOUTPUT-----:deleteThisPE end!\n");
		#endif
		if(!result){
			LOGW("something wrong when using deletePE Function!");
		}
		return result;	
	}else if(type == 6){
		int x = 0;

		time_t psRight = 0;
		time_t psWrong = cycleInput[1].cycleData[2];
		for(; x < daysInputLength; x++){
			if(daysInput[x].menstruationRecord == 1){
				psRight = daysInput[x].date;
				break;
			}
		}
		int result = 0;
		if(psRight != 0 && psWrong != 0){
			result = fixPS(psRight,psWrong,cycleInput, cyclesOutput,cyclesOutputLength,
						   userData,daysOutput,daysOutputLength);
			#ifdef TEST_ALL_PRINT
			LOGW("ALOUTPUT-----:fixPS end!\n");
			#endif
		}		
	}else if(type == 7){
		int result = inputPeriod(daysInput,daysInputLength,cycleInput,cycleInputLength,
				cyclesOutput,cyclesOutputLength,userData,
				daysOutput,daysOutputLength);
		#ifdef TEST_ALL_PRINT
		LOGW("ALOUTPUT-----:inputPeriod end!\n");
		#endif
    }
	*/else if(type == 8){
        //dayInputֻ��һ�����app�����ƶϵ���һ���û��ľ��ڿ�ʼ��
        time_t ps = daysInput[0].date;
        int result = inputVisualPeriod(ps,cycleInput, cyclesOutput,cyclesOutputLength,userData,daysOutput,daysOutputLength);
        #ifdef TEST_ALL_PRINT
        LOGW("ALOUTPUT-----:inputVisualPeriod end!\n");
        #endif
        
    }/*else if(type == 9){
    	int result = inputPeriod_V2(daysInput,daysInputLength,cycleInput,cycleInputLength,
								cyclesOutput,cyclesOutputLength,userData,
								daysOutput,daysOutputLength);
		#ifdef TEST_ALL_PRINT
		LOGW("ALOUTPUT-----:inputPeriod end!\n");
		#endif
	}else if(type == 10){
		int x = 0;
	#ifdef TEST_ALL_PRINT
		LOGW("ALOUTPUT-----:fix pe start!\n");
	#endif
		time_t peRight = 0;
		time_t peWrong = cycleInput[0].cycleData[3]>100?cycleInput[0].cycleData[3]:cycleInput[0].cycleData[1];
		for(; x < daysInputLength; x++){
			if(daysInput[x].menstruationRecord == 2){
				peRight = daysInput[x].date;
				break;
			}
		}
		int result = 0;
		if(peRight > 100 && peWrong > 100)
			result = fixPE(peRight,peWrong,cycleInput,cyclesOutput,cyclesOutputLength,
				userData,daysOutput,daysOutputLength);
	#ifdef TEST_ALL_PRINT
		LOGW("ALOUTPUT-----:fixPE end!\n");
	#endif	
		return result;
		
	}*/
	else if(type == 11){
		
		int result = BBTInputTemp(daysInput,daysInputLength,cycleInput,cyclesOutput,cyclesOutputLength,daysOutput,daysOutputLength,userData); 
		#ifdef TEST_ALL_PRINT
		LOGW("ALOUTPUT-----:BBTInputTemp end!\n");
		#endif
		if(result == ERROR_CODE){
			LOGW("something wrong when using BBTInputTemp Function!");
		}
		return result;
	}else if(type == 12){
		int result = mucusInput(daysInput,daysInputLength,cycleInput,cyclesOutput,
			cyclesOutputLength,userData,daysOutput,daysOutputLength );
		#ifdef TEST_ALL_PRINT
		LOGW("ALOUTPUT-----:mucusInput end!\n");
		#endif
		if(result == ERROR_CODE){
			LOGW("something wrong when using mucusInput Function!");
		}
		return result;
	}else if(type == 13){
		int result = inputTestOV(daysInput,daysInputLength,cycleInput,cyclesOutput,cyclesOutputLength,
								 userData,daysOutput,daysOutputLength); 
		#ifdef TEST_ALL_PRINT
		LOGW("ALOUTPUT-----:inputTestOV end!\n");
		#endif
		if(result == ERROR_CODE){
			LOGW("something wrong when using recordInput Function!");
		}
		return result;
		
	}else if(type == 14){
		int result = deleteTestOV(daysInput,daysInputLength,cycleInput,cyclesOutput,cyclesOutputLength,
								 userData,daysOutput,daysOutputLength); 
		#ifdef TEST_ALL_PRINT
		LOGW("ALOUTPUT-----:deleteTestOV end!\n");
		#endif
		if(result == ERROR_CODE){
			LOGW("something wrong when using recordDelete Function!");
		}
		return result;
		
	}else if(type == 102){
		
		int result = transV1TOV2DS_V2_Filer(daysInputLength,daysInput,daysOutput,
					cyclesOutput,userData,daysOutputLength,cyclesOutputLength);
		#ifdef TEST_ALL_PRINT
		LOGW("ALOUTPUT-----:transV1TOV2DS end!\n");
		#endif
		if(result == ERROR_CODE){
			LOGW("something wrong when using mucusInput Function!");
		}
		return result;
	}else if(type == 202){
		
		int result = transV1TOV2DS_V2_Filer(daysInputLength,daysInput,daysOutput,
					cyclesOutput,userData,daysOutputLength,cyclesOutputLength);
		#ifdef TEST_ALL_PRINT
		LOGW("ALOUTPUT-----:transV1TOV2DS end!\n");
		#endif
		if(result == ERROR_CODE){
			LOGW("something wrong when using mucusInput Function!");
		}
		return result;
	}/*else if(type == 21){
		#ifdef TEST_ALL_PRINT
		LOGW("ALOUTPUT-----:changePastInfo_inputPeriod end!\n");
		#endif
		int result = changePastInfo_inputPeriod_filer(daysInputLength,daysInput,cycleInput,cycleInputLength,daysOutput,
					cyclesOutput,userData,daysOutputLength,cyclesOutputLength);
		#ifdef TEST_ALL_PRINT
		LOGW("ALOUTPUT-----:changePastInfo_inputPeriod end!\n");
		#endif
		if(result == ERROR_CODE){
			LOGW("something wrong when using changePastInfo_inputPeriod Function!");
		}
		return result;
	}else if(type == 22){
		#ifdef TEST_ALL_PRINT
		LOGW("ALOUTPUT-----:changePastInfo_deletePeriod end!\n");
		#endif
		int result = changePastInfo_deletePeriod(daysInputLength,daysInput,cycleInput,cycleInputLength,daysOutput,
					cyclesOutput,userData,daysOutputLength,cyclesOutputLength);
		#ifdef TEST_ALL_PRINT
		LOGW("ALOUTPUT-----:changePastInfo_deletePeriod end!\n");
		#endif
		if(result == ERROR_CODE){
			LOGW("something wrong when using changePastInfo_deletePeriod Function!");
		}
		return result;
	}*/else if(type == 23){
		#ifdef TEST_ALL_PRINT
		LOGW("ALOUTPUT-----:changePastInfo_inputBBT start!\n");
		#endif
		int result = changePastInfo_inputBBT(daysInputLength,daysInput,cycleInput,cycleInputLength,daysOutput,
					cyclesOutput,userData,daysOutputLength,cyclesOutputLength);
		#ifdef TEST_ALL_PRINT
		LOGW("ALOUTPUT-----:changePastInfo_inputBBT end!\n");
		#endif
		if(result == ERROR_CODE){
			LOGW("something wrong when using changePastInfo_inputBBT Function!");
		}
		return result;
	}else if(type == 24){
		#ifdef TEST_ALL_PRINT
		LOGW("ALOUTPUT-----:changePastInfo_inputRecord start!\n");
		#endif
		int result = changePastInfo_inputRecord(daysInputLength,daysInput,cycleInput,cycleInputLength,daysOutput,
					cyclesOutput,userData,daysOutputLength,cyclesOutputLength);
		#ifdef TEST_ALL_PRINT
		LOGW("ALOUTPUT-----:changePastInfo_inputRecord end!\n");
		#endif
		if(result == ERROR_CODE){
			LOGW("something wrong when using changePastInfo_inputRecord Function!");
		}
		return result;
	}else if(type == 25){
		#ifdef TEST_ALL_PRINT
		LOGW("ALOUTPUT-----:changePastInfo_inputRecord start!\n");
		#endif
		int result = changePastInfo_inputRecord(daysInputLength,daysInput,cycleInput,cycleInputLength,daysOutput,
					cyclesOutput,userData,daysOutputLength,cyclesOutputLength);
		#ifdef TEST_ALL_PRINT
		LOGW("ALOUTPUT-----:changePastInfo_inputRecord end!\n");
		#endif
		if(result == ERROR_CODE){
			LOGW("something wrong when using changePastInfo_inputRecord Function!");
		}
		return result;
	}else if(type == 26){
		int x = 0;
	#ifdef TEST_ALL_PRINT
		LOGW("ALOUTPUT-----:fix pe start!\n");
	#endif
		time_t peRight = 0;
		time_t peWrong = cycleInput[0].cycleData[3]>100?cycleInput[0].cycleData[3]:cycleInput[0].cycleData[1];
		for(; x < daysInputLength; x++){
			if(daysInput[x].menstruationRecord == 2){
				peRight = daysInput[x].date;
				break;
			}
		}
		int result = 0;
		if(peRight > 100 && peWrong > 100)
			result = fixOldPE(peRight,peWrong,cycleInput,cyclesOutput,cyclesOutputLength,
				userData,daysOutput,daysOutputLength);
	#ifdef TEST_ALL_PRINT
		LOGW("ALOUTPUT-----:fixPE end!\n");
	#endif	
		return result;
		
	}
	return true;
	
}

bool inputAlForAndroid(int type){
	return true;
}








